package com.xyht.medicine_management_system.modules.medicine.controller;


import com.xyht.medicine_management_system.auth.util.JwtTokenUtil;
import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.medicine_management_system.modules.medicine.service.MmsMedicineFootprintService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 药品足迹 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-12-05
 */
@RestController
@SecretBody
@RequestMapping("/medicine/footprint")
public class MmsMedicineFootprintController {


    @Resource
    private MmsMedicineFootprintService medicineHistoryService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @ApiModelProperty("查看自己的足迹")
    @GetMapping("/list")
    public ResponseResult getMyFootprintList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                             @RequestParam(value = "footprintDateStr",required = false) String footprintDateStr,
                                             HttpServletRequest request){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return medicineHistoryService.getMyFootprintList(pageNum,pageSize,footprintDateStr,userId);
    }

    @ApiModelProperty("查看更多")
    @GetMapping("/getOtherList")
    public ResponseResult getOtherMyFootprintList(@RequestParam(value = "footprintDate") String footprintDate,
                                             HttpServletRequest request){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return medicineHistoryService.getOtherMyFootprintList(userId,footprintDate);
    }


}

